/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import MemberOperation.MemberThreadOperation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author root
 */
public class RankPost extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        int rankoperation=0;
        System.out.println(" i am rank postttttttttttttttttttttttttttttttttttt");
     String rank=   request.getParameter("rank");
     
        System.out.println(" ss======================================"+rank);
        String postid=request.getParameter("postid");
        System.out.println(" post id is"+postid);
       int memId= (Integer)request.getSession().getAttribute("id");
        System.out.println(" memeber id is"+memId);
        MemberOperation.MemberThreadOperation op=new MemberThreadOperation();
        
        if(rank.equals("bad"))
            rankoperation=2;
        
        if(rank.equals("fair"))
            rankoperation=4;
        
        if(rank.equals("good"))
            rankoperation=6;
        
        if(rank.equals("verygood"))
            rankoperation=8;
        
          if(rank.equals("excellent"))
            rankoperation=10;
        
        
        
        
        
        
        op.RankPost(memId,Integer.parseInt(postid),rankoperation );
        return mapping.findForward("voted");
    }
}
